package com.briup.springboot_web.web.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/*
* 创建springMVC 提供拦截器，实现拦截器的接口
*
*
* */
@Component //表示创建一个拦截器对象，并拦截器对象添加ioc容器
public class MyInterceptor implements HandlerInterceptor {
    //当用户发送请求时，拦截器会进行拦截，拦截到preHandle方法中，通过逻辑判断确定是否通过拦截
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("正在进行拦截...");
        //return false; //拦截不通过
        return true;// 拦截通过
    }
}
